package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {

    @Select("SELECT * FROM user WHERE openid = #{openid}")
    User selictByOpenId(String openid);

    void insert(User user);

    // 根据用户ID查询用户信息
    @Select("SELECT * FROM user WHERE id = #{id}")
    User getById(Long userId);

    // 查询每日新增用户数与总用户量
    @Select("SELECT COUNT(*) FROM user WHERE create_time < #{endTime}")
    Integer selectUserCountByDay( LocalDateTime endTime);

    @Select("SELECT COUNT(*) FROM user WHERE create_time > #{beginTime} and create_time < #{endTime}")
    Integer selectUserAddCountByDay(LocalDateTime beginTime, LocalDateTime endTime);
}
